<!DOCTYPE html>
<html lang="UTF-8" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script th:src="@{/static/jquery/jquery-2.1.1.min.js}"></script>
    <script type="text/javascript" th:src="@{/static/jquery/jquery-2.1.1.min.js}"></script>
    <script type="text/javascript" th:src="@{/static/layer/layer.js}"></script>

    <script>
        $(document).ready(function () {
            $("#ajax01").click(function () {
                // 准备要发送的数组
                var array = [5, 8, 12];
                // 将 JSON 数组转换成 JSON 字符串
                // "[5,8,12]" var arrayStr = JSON.stringify(array);
                var arrayStr = JSON.stringify(array)
                // 发送 Ajax 请求
                $.ajax({
                    "url": "send/array/plan/one.html",
                    "type": "post",
                    "data": arrayStr, // JSON 字符串作为请
                    "contentType": "application/json;charset=UTF-8",// 告诉服务器端当前请求的请求体是JSON 格
                    success: function (response) {
                        console.log(response);
                    },
                    error: function (response) {
                        console.log(response);
                    }

                })
            });
            $("#ajax02").click(function () {
                // 准备要发送的 JSON 数据
                var student = {
                    "stuId": 999,
                    "stuName": "tom",
                    "stuAge": 23,
                    "address": {
                        "province": "shandong",
                        "city": "heze",
                        "street": "hello"
                    },
                    "schoolList": [
                        {
                            "schoolName":"schoolONe",
                            "schoolSize":500
                        },{
                            "schoolName":"schoolTwo",
                            "schoolSize":1000
                        },{
                            "schoolName":"schoolThree",
                            "schoolSize":2000
                        }
                    ],
                    "scoreMap": {
                         "yingyu": 100,
                         "shuxue": 80,
                         "wuli": 90
                    }
                };
// 将 JSON 对象转换为 JSON 字符串
                var requestBdoy = JSON.stringify(student);
                // 发送 Ajax 请求
                $.ajax({
                    "url": "save/student.html",
                    "type": "post",
                    "data": requestBdoy, // JSON 字符串作为请
                    "contentType": "application/json;charset=UTF-8",// 告诉服务器端当前请求的请求体是JSON 格
                    success: function (response) {
                        console.log(response);
                    },
                    error: function (response) {
                        console.log(response);
                    }

                })
            });
            $("#layer01").click(function () {

                layer.msg("这里是 layer 弹出的消息！");
            })
        })
    </script>
</head>
<body>
templates
    <a th:href="@{/test/ssm.html}">测试SSM整合环境</a><br>
    <button id="ajax01">ajax01</button><br>
    <button id="ajax02">ajax02</button><br>
    <button id="layer01">layer01</button><br>
</body>
</html>